package main;

import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;

/**
 * This is the view of the main-part of the application.
 * It provides the menu and manages the spaces for
 * all plugins
 * 
 * @author daishy
 * @date 02.04.2008 21:22:53
 *
 */
public class Mainview extends JFrame
{
	
	/**
	 * Default SerialVersionID 
	 */
	private static final long serialVersionUID = 1L;
	
	/**
	 * This is the controller of this view
	 */
	private Maincontroller controller;
	
	
	/**
	 * CTor creates the size and so on for the Frame
	 */
	public Mainview(Maincontroller controller)
	{
		super("Titan Forge Developer Edition");
		setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); 
		setSize(500, 500);
		installMenu();
		
		this.controller = controller;
		
		setVisible(true);
	}
	
	
	/**
	 * This method installs the Menubar for the Frame.
	 * 
	 */
	private void installMenu()
	{
		JMenuBar menu = new JMenuBar();
			
		// Filemenu
		JMenu file = new JMenu("File");
		file.add(new AbstractAction("Exit")
		{
			private static final long serialVersionUID = 1L;
			
			public void actionPerformed(ActionEvent e) {
				setVisible(false);
				dispose();				
			}
		});
		
		// settingsmenu
		JMenu settings = new JMenu("Settings");
		settings.add(new AbstractAction("Settings") {
			private static final long serialVersionUID = 1L;
			
			public void actionPerformed(ActionEvent e) {
				controller.showSettings();
			}
		});
		
		//Dicemenu
		JMenu dice = new JMenu("Dice");
		dice.add(new AbstractAction("Dice")
		{
			private static final long serialVersionUID = 1L;
			
			public void actionPerformed(ActionEvent e)
			{
				controller.showSettings();
			}
		});
		
		menu.add(file);
		menu.add(settings);
		menu.add(dice);
			
		setJMenuBar(menu);
	}
}
